Page 97 - 2629_Devagiri_C-6
P. 97

By enclosing the text within triple quotes (''' or """):

                 '''                                                             """
                 This is a                                                       This is a
                 multiline comment                            OR                 multiline comment
                 '''                                                             """
                  Program 2    To demonstrate how to use both single-line and multiline comments.


                     Program2.py
                  File  Edit  Format   Run    Options  Window     Help
                                                                                      Write a Python program to

                  #This is a single line comment.                                      display comments about
                                                                                     your best friend in multi line
                  print("Orange Education")
                                                                                    comments and print his name
                  '''
                                                                                      using the print statement.
                  This is a
                  multiline comment
                  using triple quotes                                               Output
                  '''
                                                                                 Orange Education
                  print("I love Python")                                         I love Python





                        OPERATORS


                 Operators are symbols that perform mathematical, logical or relational operations on values
                 called operands. For example, in 15 + 7, 15 and 7 are operands and + is the operator. Python has
                 different categories of operators.

                 ARITHMETIC OPERATORS

                 Arithmetic  operators perform arithmetic  operations  between  two operands. The  arithmetic
                 operators are defined in the following table:

                                                                                               Example
                  Operator        Name                         Description                                  Output
                                                                                             (x = 5, y = 3)
                      +       Addition          Adds values on either side of the operator.      x + y         8
                      -       Subtraction       Subtracts the right operand from the left        x - y          2
                                                operand.
                      *       Multiplication    Multiplies  values on either  side  of the       x * y         15
                                                operator.
                      /       Division          Divides the left operand by the right and        x / y       1.6667
                                                returns a float.
                      %       Modulus           Divides the left operand by the right and        x % y          2
                                                returns the remainder.





                                                                                                                  95
                                                                                              Python–Start to Code
   92   93   94   95   96   97   98   99   100   101   102